<template>
	<view>
		<van-tabs :active=" active " @click="onChange">
			<van-tab :title="item.name" v-for="(item,index) in list.navData" :key="item.id">
				<ul>
					<li v-for="items in lists" :key="items.id">
						<img :src="items.list_pic_url" alt="">
						<p>{{ items.name }}</p>
						<p>￥{{ items.retail_price }}</p>	
					</li>
				</ul>
			</van-tab>
		</van-tabs>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [],
				lists: [],
				active: 0
			}
		},
		methods: {
			async add(id) {
				let {
					data
				} = await this.axios.get('http://shop.bufantec.com/bufan/category/categoryNav?id=1005000')
				this.list = data
			},
			async gets(a) {
				let {
					data
				} = await this.axios.get('http://shop.bufantec.com/bufan/goods/goodsList?categoryId=' + a)
				this.lists = data.data
			},
			onChange(e) {
				console.log(e);
				var index = e.detail.index
				let a = this.list.navData[index].id
				this.gets(a)
			}
		},
		onLoad(a) {
			this.add();
			this.gets(a.id);
			if (a.id == '1005000') {
				this.active = 0;
			} else if (a.id == '1005001') {
				this.active = 1;
			} else if (a.id == '1005002') {
				this.active = 4;
			} else if (a.id == '1008000') {
				this.active = 3;
			} else if (a.id == '1019000') {
				this.active = 8;
			}
		}
	}
</script>

<style lang='scss'>
	ul {
		width: 100%;
		padding: 0 20rpx;
		box-sizing: border-box;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;

		li {
			width: 49%;
			height: 400rpx;
			// background: #ccc;
			margin-top: 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: center;
			align-items: center;

			img {
				width: 100%;
				height: 80%;
			}

			p {
				font-size: 28rpx;
			}

			.price {
				color: orange;
			}
		}
	}
</style>
